package games.tankwars.behaviors;

public class IntersectAndRemoveBoth extends IntersectAndStop
{
    protected vooga.core.AbstractLevel myLevel;


    public IntersectAndRemoveBoth (vooga.geom.Vector velocity,
                               vooga.entities.Entity obstacle,
                               vooga.core.AbstractLevel level)
    {
        super(velocity, obstacle);
        myLevel = level;
    }

    public IntersectAndRemoveBoth (vooga.geom.Vector velocity,
                               java.util.List<vooga.entities.Entity> obstacles,
                               vooga.core.AbstractLevel level)
    {
        super(velocity, obstacles);
        myLevel = level;
    }
    
    public IntersectAndRemoveBoth (vooga.geom.Vector velocity,
            java.util.Collection<vooga.entities.Entity> obstacles,
            vooga.core.AbstractLevel level)
    {
    	super(velocity, obstacles);
	myLevel = level;
	}


    protected void onCollide (vooga.entities.Entity lhs, vooga.entities.Entity rhs)
    {
        super.onCollide(lhs, rhs);
        
        myLevel.removeEntity(rhs.getClass().cast(rhs));
        System.out.println(rhs.getClass().getName());
        //myLevel.removeEntity(rhs.getClass().cast(vooga.util.Reflection.createInstance(rhs.getClass().getName())));
        remove(rhs);
        myLevel.removeEntity(lhs.getClass().cast(lhs));
        System.out.println(lhs.getClass().getName());
        //myLevel.removeEntity(rhs.getClass().cast(vooga.util.Reflection.createInstance(rhs.getClass().getName())));
        remove(lhs);
        rhs.setVisible(false);
        lhs.setVisible(false);
    }
}

